Tool   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 5

3 Functions

Rating   Name   Duplication   Size   Complexity  
A isInstalled 0 2 1
A install 0 9 2
A uninstall 0 13 2
1
import OS from '../client/OS'
2
import {error, info, success} from '../utils/console'
3
4
abstract class Tool {
5
6
    abstract name: string
7
    abstract alias: string
8
9
    /**
10
     * Install the app.
11
     */
12
    install = async (): Promise<boolean> => {
13
        if (await this.isInstalled()) {
14
            error(`${this.name} already is installed.`)
15
            return false
16
        }
17
18
        info(`Installing ${this.name}...`)
19
        await OS.getInstance().packageManager.install(this.alias, false)
20
        return true
21
    }
22
23
    /**
24
     * Uninstall the app.
25
     */
26
    uninstall = async (): Promise<boolean> => {
27
        if (!(await this.isInstalled())) {
28
            error(`${this.name} is not installed.`)
29
            return false
30
        }
31
32
        info(`Uninstalling ${this.name}...`)
33
34
        await OS.getInstance().packageManager.uninstall(this.alias, false)
35
36
        success(`Uninstalled ${this.name}.`)
37
38
        return true
39
    }
40
41
    /**
42
     * Check if app the is already installed..
43
     */
44
    isInstalled = async (): Promise<boolean> => {
45
        return OS.getInstance().packageManager.packageIsInstalled(this.alias)
46
    }
47
48
}
49
50
export default Tool
51